from django.contrib import admin
import models


# Register your models here.
class SubmitedLeaveAdmin(admin.ModelAdmin):
    list_display = ('id','staff', 'category', 'start_time', 'end_time', 'reason', 'status')


class UsedLeaveAdmin(admin.ModelAdmin):
    list_display = ('staff', 'category', 'start_time', 'end_time', 'matched')


class MsgAdmin(admin.ModelAdmin):
    list_display = ('id','staff', 'category', 'status', 'gen_time')


class AvaiLeaveAdmin(admin.ModelAdmin):
    list_display = ('staff', 'category', 'span', 'start_date', 'is_valid')


class RelationAdmin(admin.ModelAdmin):
    list_display = ('avai_leave', 'avai_leave_start', 'avai_leave_end',
                    'used_leave', 'used_leave_start', 'used_leave_end')


class AttendRecordAdmin(admin.ModelAdmin):
    list_display = ('staff', 'workshift', 'date', 'enter_time', 'leave_time', 'workspan', 'late_level',
                    'late_person', 'late_team', 'overtime', 'absent', 'early_leave', 'timestr')
    search_fields = ['staff']

    def workshift(self, instance):
        return instance.staff.workshift


class AttdenReportAdmin(admin.ModelAdmin):
    list_display = ('staff', 'start_date', 'due_date', 'person_leave', 'sick', 'annual', 'other_paid_leave',
                    'swap_off', 'paid_leave', 'late1', 'late2', 'late3', 'late4', 'late_person',
                    'late_team', 'overtime', 'exp_workday', 'act_workday', 'allow_day', 'leave_day',
                    'deduction_day', 'absent', 'early_leave', 'full_attend', 'process')
    search_fields = ['staff']


class SpecialWorkshiftAdmin(admin.ModelAdmin):
    list_display = ('date', 'workshift', 'is_workday')


admin.site.register(models.LeaveApplication, SubmitedLeaveAdmin)
admin.site.register(models.LeaveModel, UsedLeaveAdmin)
admin.site.register(models.MsgModel, MsgAdmin)
admin.site.register(models.AvaiLeave, AvaiLeaveAdmin)
admin.site.register(models.ConsumeRelation, RelationAdmin)
admin.site.register(models.AttendRecord, AttendRecordAdmin)
admin.site.register(models.AttendReport, AttdenReportAdmin)
admin.site.register(models.SpecialWorkshift, SpecialWorkshiftAdmin)
